package com.jasypt.test;
import org.jasypt.encryption.StringEncryptor;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.fasterxml.jackson.databind.deser.Deserializers;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;

/**
 * 
 * Title: EncryptJasypt.java
 * Description: Jasypt 加密properties中的数据库密码
 * Copyright: Copyright (c) 2018
 * Company: Sco.Hee
 * @author Sco.Hee
 * @date 2018年9月14日
 * @version 1.0
 */

@EnableEncryptableProperties
@SpringBootTest(classes=Deserializers.Base.class)
@RunWith(SpringRunner.class)
public class EncryptJasypt {
    @Autowired
    StringEncryptor stringEncryptor;//密码解码器注入

    @org.junit.Test
    public void test() {
        System.out.println("生成加密后的数据库用户名："+stringEncryptor.encrypt("root"));
        System.out.println("生成加密后的数据库密码：    "+stringEncryptor.encrypt("admin888"));
    }
}